import { makeAutoObservable } from 'mobx'
import { history } from '@/utils/history'
// import { http, setToken, getToken } from '@/utils/index'
import { setToken, getToken } from '@/utils/index'
import { message } from 'antd';

class LoginStore {
    token = getToken() || ""
    
    constructor() {
        //响应式
        makeAutoObservable(this)
    }
    getToken = async({ mobile, code })=>{
        //调用登录接口存入token
        // const res = await http.post('http://geek.itheima.net/v1_0/authorizations',{
        //     mobile,
        //     code
        // })
        // this.token = res.data.token
        // 将token存入ls
        // setToken(this.token)
        if( mobile==="liumy" && code==="15093465600" ) {
            history.push('/')
            const token = 'token123456789'
            setToken(token)
            window.localStorage.setItem("userInfo",mobile)
            message.success('登录成功!')
        }
    }
}

export default LoginStore